#!/bin/bash
packageDIR="./unsupervisedMicroarray/"
testsScript="./unsupervisedMicroarray/tests/doRUnit.R"
packageName=`basename $packageDIR`


if [ $# -gt 0 ]; then
	if [ $1 = "check" ]; then
		echo  -e "checking package...\n"
		R CMD check "$packageDIR"
		echo  -e "checking done"
	fi
	
fi
#delete backup files
echo "Deleting backup files... $packageDIR"
find "$packageDIR" -type f -name "*~" -exec rm -rf {} \;

#build package 
#R CMD build "$packageDIR"
# optional package checking

#install package for one user
R CMD INSTALL "$packageDIR"

#optional unit tests
if [ $# -gt 0 ]; then
	if [ $1 = "test" ]; then
		echo "Run RUnit Tests"
		R --vanilla --slave < "$testsScript"
		echo "Testing done"
	fi	
fi
